package com.mogist.hqc.module.product.presenter

import com.mogist.hqc.entitys.BaseResponse
import com.mogist.hqc.entitys.response.MainProductListVo
import com.mogist.hqc.module.product.contract.Product0Contract
import com.mogist.hqc.mvp.HttpDto
import com.mogist.hqc.mvp._PresenterImpl
import com.mogist.hqc.util.Constant
import talex.zsw.basecore.util.JsonTool
import talex.zsw.basecore.view.other.RxToast

/**
 * 作用：玩家产品列表
 * 作者：赵小白 email:vvtale@gmail.com  
 * 修改人：
 * 修改时间：
 * 修改备注：
 */
class Product0Presenter(view: Product0Contract.View) : _PresenterImpl<Product0Contract.View, BaseResponse>(
        view), Product0Contract.Presenter
{
    override fun requestSuccess(response: BaseResponse, http: HttpDto)
    {
        when (http.url)
        {
            Constant.MAIN_PRODUCT ->
            {
                mView.disLoading()
                if (response.success)
                {
                    mView.disDialog()
                    val vo = JsonTool.getObject(response.content, MainProductListVo::class.java)
                    mView.bindData(vo)
                }
                else
                {
                    mView.disDialog()
                    response.message?.let {
                        RxToast.error(it)
                    }
                }
            }
        }
    }

    override fun requestError(msg: String?, httpDto: HttpDto?)
    {
        mView.disLoading()
        super.requestError(msg, httpDto)
    }
}